package list;

public class LeetCode206 {

    public ListNode reverseList(ListNode head) {
        if (head == null) return null;
        ListNode res = null;
        ListNode p = head;
        while (p != null) {
            ListNode next = p.next;
            p.next = res;
            res = p;
            p = next;
        }
        return res;
    }
}
